package com.iking.toolkit.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

/**
 * @Author monkey
 * @Date 2022/4/12 11:09
 */
@Configuration
public class MyBatisPlusConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", new Date(), metaObject);
        this.setFieldValByName("updateTime", new Date(), metaObject);
//        this.setFieldValByName("isSysDefault", false, metaObject);
//        this.setFieldValByName("isDefault", false, metaObject);
        this.setFieldValByName("isDelete", false, metaObject);
        this.setFieldValByName("isEnable", true, metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", new Date(), metaObject);
    }
}
